package com.code.day16.b_thread;

public class Product implements Runnable{
    private BaoZiPu bzp;
    public Product(BaoZiPu bzp) {
        this.bzp = bzp;
    }

    @Override
    public void run() {

        while(true) {

            try {
                Thread.sleep(100l);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (bzp) {

                // 生产完包子判断
                if (bzp.isFlag()){
                    try {
                        bzp.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                bzp.setCount();
                bzp.setFlag(true);
                bzp.notify();


            }

        }

    }
}
